<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>华胜后台管理</title>
		<link rel="stylesheet" type="text/css" href="css/unified.css">
		<script src="plugins/layui/layui.js"></script>
		    <style>
    	#leftMenuTree span[menu-id]{
    		cursor:pointer;
    	}
    	#leftMenuTree li{
    		display: table;
    		user-select:none;
    	}
    	.show_form .layui-input-block{
    		width: 90%;
    	}
    	.souquan{
    		display: none;
			position: absolute;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;
			margin: auto;
			width: 100%;
			height: 100%;
			background-color: white;
			z-index: 1002;
			border-radius: 6px;
			overflow: auto;
			box-shadow: 5px 5px 5px -3px #333;
    	}
    	.souquan_index ul,.souquan_system ul{
    		padding-left:15px;
    	}
    	.souquan_left{
    		position:relative
    		width: 30%;
			height: 420px;
    		float: left;
    		overflow:yes;
    		padding-left: 7%;
    		border-right: 1px dotted #666666;
    	}
    	.souquan_left span{
    		cursor: pointer;
    	}
    	.souquan_right{
    		width: 60%;
			height: 420px;
    		float: right;
    	}
    	.souquan_right ul{
    		margin-top: 20px;
    	}
    	.souquan_right ul li{
    		margin-top: 10px;
    	}
    	.souquan_right p,.souquan_right ul li{
    		text-align: center;
    	}
    	.redFont{
    		color:red;
    	}
    </style>
	</head>

	<body>

		<div class="breadcrumbnav">
			<span class="layui-breadcrumb " lay-separator="·">
	          <a ><cite>首页</cite></a>
	          <a ><cite>系统管理</cite></a>
	          <a ><cite>系统角色管理</cite></a>
	        </span>
		</div>
		<div class="kit-doc">
			<!-- 标题 -->
			<div class="kit-doc-title">
				<fieldset>
					<legend>
						<a name="blockquote">系统角色</a>
					</legend>
				</fieldset>
			</div>
			<!-- 标题 end-->

			<!-- 概述 -->
			<div class="boderbox">
				<div class="rowtop">
					<button class="layui-btn addbtn openwinbtn " onclick="createPopup('添加系统角色');" >添加+</button>
					
					<form class="layui-form searchform" action="" id="comSearchForm">
						 <label class="layui-form-label">角色名称:</label>
						<div class="layui-input-inline">
							<input type="text" name="text" required lay-verify="required" placeholder="输入关键字" autocomplete="off" class="layui-input" id="demoReload">
						</div>
						<div class="layui-btn-group">
							<div class="layui-btn openwinbtn" data-method="reload" id="searchButton" id="searchButton" onclick="doSearch();">查询</div>
							<div class="layui-btn layui-btn-normal openwinbtn" data-method="returnTable">重置</div>
						</div>
					</form>
				</div>
				
				
				

				<div class="layui-tab-content notab">
					<div class="layui-tab-item layui-show">
						<table class="layui-table " lay-filter="table100" id="SAtable"></table>
					</div>
				</div>
				
				<div class="souquan">
 		<blockquote class="layui-elem-quote titleCb3412">
			角色/授权  > <span>角色授权</span><button class="layui-btn layui-btn-primary rightbtn" onclick="closeSou();"  style="margin-top: 0px;">X</button> 
    	</blockquote>
		<hr />
		<input type="hidden" id="curRoleId" value="">
 		<div id="leftMenuTree" style="position:relative;width:25%;height:78%;float:left;overflow:auto;margin-left: 20%; ">
 			 		
 		</div>
 		<!--<div  style="position:relative;width:50%;height:78%;float:left;overflow: auto;text-align: center;">
 			<p class="rolename">当前给【<span id="theRoleName">财务</span>】角色授权：<input id="theCheckAll" type="checkbox" onclick="checkCurrentAllFunction(this);"/><span>全选/全不选</span></p>
 			<div id="rightUpFunction">
 				
 			</div>
 		</div>-->
 		<div id="rightDownBtn" style="position:relative;width:100%;height:50px;float:left;;">
			<button class="layui-btn layui-btn-lg layui-btn-normal" style="margin: auto;display: table;" onclick="saveRoleMenuAndFunction();">提交</button>
		</div>
 	</div>
				


		</div>
		
	</div>
	<script src="js/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="js/allajax.js"></script>
	 <script src="../js/jquery1/store.js" type="text/javascript"></script>
    <script src="../js/initConfig.js?0002" type="text/javascript"></script>
	 <script src="../js/common.js?0002" type="text/javascript"></script>
	  <script src="js/admin_function_permission.js" type="text/javascript"></script>
	  <script src="js/pagetoolbar_for_layui.js"></script>
	<!--<script type="text/javascript" src="js/comMent.js" ></script>-->
  <script>
	
var loading;
layui.use([ 'layer', 'form', 'element', 'table', 'laydate' ],function() {
	var layer = layui.layer, form = layui.form, element = layui.element, table = layui.table, laydate = layui.laydate;
	
	$("#searchButton").trigger("click");
})
disRedFont();
function doSearch(isPage){
	loading = layer.load(2, {time: 0}); 
	var searchJson = convertUrlParamStrToJSON($(".searchform").serialize());

	searchJson.pageSize=$(".tablePageSize").eq(0).val();
	searchJson.pageNo=isPage?$(".gotoPageNo").eq(0).val():1;
	console.log(JSON.stringify(searchJson));
	
		AjaxPostFn( '/system/roleControl/listConsoleRole.do', JSON.stringify(searchJson), function(jsonData) {

			if (jsonData.resultCode == "200") {
					layer.close(loading);
					var data = jsonData.list;
				  	console.log(data); 
				  	var newJson = [];
				  	for(var i=0;i<data.length;i++){
			  			newJson[i] = {
				  		'a1':data[i].name,
			  			'a2':data[i].description,
			  			'a3':formatDate(data[i].createTime),
			  			'a4':`<a class='layui-btn layui-btn-decoration layui-btn-xs bluesize ' id="authorization" roleid="${data[i].id}" rolename="${data[i].name}" onclick="showSou(this)">授权</a>
								<a class='layui-btn layui-btn-decoration layui-btn-xs bluesize '  roleid="${data[i].id}" onclick="popupAddOrUpdate('${data[i].id}')">修改</a>
								<a class='layui-btn layui-btn-decoration layui-btn-xs bluesize ' onclick="delete_role()" parentId="${data[i].id}">删除</a>`
				  		};
				  	}
					layui.use(['layer', 'form', 'element','table','laydate'], function(){
				  	var layer = layui.layer
				     	,form = layui.form
				      	,element = layui.element
				      	,table = layui.table
				      	,laydate = layui.laydate;
				    laydate.render({ elem: '#timeSolt', type: 'datetime', range: "~"});
				
					//展示已知数据
					table.render({
					    elem: '#SAtable'
					    ,cols: [[ //标题栏
							{field:'a1', title:'角色名称'}
					        ,{field:'a2', title:'角色备注' }
					        ,{field:'a3',  title:'创建时间'}
					        ,{field:'a4',  title:'操作'}
					    ]]
					    ,data: newJson
					    ,size:'lg'
					    ,even:true
					    ,limit: $(".tablePageSize").eq(0).val()
					    ,cellMinWidth:200
					    ,skin:"line"
					    ,align:"center"
					    ,page: false //是否显示分页	
					    
					});
					renderPageToolBar(jsonData,"pagination","doSearch(true)");
					dataReadyCheckPermission();
				})
			}else {
				layer.open({
				  	title: '失败'
				  	,content:jsonData.resultMessage
				});			
			}
		})
	return false;
}
	
function createPopup(headTitle){
    var popupContent = '<form class="layui-form" id="add_or_edit_form">'+
    						'<input type="hidden" id="edit_form_id" name="id" value="">'+
                            '<div class="layui-form-item layui-input-container taxIdentificationNumber-container">'+
                                '<div class="layui-public-input">'+
                                    '<input type="text" id="cooperativeName" name="name" required lay-verify="required" placeholder="请输入角色名称" autocomplete="off" class="layui-input">'+
                                '</div>'+
                            '</div>'+
                            '<div class="layui-form-item layui-input-container taxIdentificationNumber-container">'+
                                '<div class="layui-public-input">'+
                                	'<textarea name="description" style="width100%;height:150px" class="layui-input" placeholder="请输入角色备注"></textarea>'+
                                '</div>'+
                            '</div>'+
                            '<div class="layui-form-item layui-input-container layui-btn-container"">'+
                                '<div class="layui-public-input layui-public-btn">'+
                                    '<button type="button" class="layui-btn layui-submit-btn"  id="edit_form_btn" lay-submit="" lay-filter="add_or_edit_form">提交</button>'+
                                '</div>'+
                            '</div>'+
                        '</form>';

	var popupTitle ='<span class="layui-breadcrumb " lay-separator=">" style="visibility: visible;">'+
						'<a><cite>角色授权管理</cite>'+
						'</a><span lay-separator="">&gt;</span>'+
						'<a><cite>'+headTitle+'</cite></a>'+
			        '</span>';
    var open = layer.open({
        type: 1,
        area: ['480px','450px'],
        title: popupTitle,
        content : popupContent,
        cancel: function(index, layero){ 
        }    
    });



	

    // 渲染
    layui.use('form', function(){
        var form = layui.form; 
        form.render();     
    });

	
	layui.use([ 'layer', 'form', 'element', 'table', 'laydate' ],function() {
	var layer = layui.layer, form = layui.form, element = layui.element, table = layui.table, laydate = layui.laydate;
	
	/**
	*触发保存表单,为了layui的美化信息必须输入提示框
	*/
		form.on('submit(add_or_edit_form)', function(data){
		
			var saveJson = convertUrlParamStrToJSON($("#add_or_edit_form").serialize());
			console.log(JSON.stringify(saveJson));
			disableTheButton($("#edit_form_btn"));
			AjaxPostFn( '/system/roleControl/saveConsoleRole.do', JSON.stringify(saveJson), function(jsonData) {
				if (jsonData.resultCode == "200") {
					layer.close(open);
					doSearch();
					layer.msg('保存成功');
				} else {
					layer.msg(jsonData.resultMessage);
					enableTheButton($("#edit_form_btn"));
				}
			});
		
		
		
		//不return false会刷新网页
		return false;
		});
	
	});
}
	
function popupAddOrUpdate(theDataId){
	theDataId=theDataId||'';
	if (theDataId.length > 0) {
		$("#edit_form_id").val(theDataId);
		createPopup("修改系统角色");
		AjaxPostFn( '/system/roleControl/getConsoleRole.do','{"id" : theDataId}',function(jsonData) {
			if (jsonData.resultCode == "200") {
				console.log(JSON.stringify(jsonData));
				//将json数据放到id为add_or_edit_form的form表单中
				putJsonToForm(jsonData,"add_or_edit_form");
				//各别数据处理
				console.log("jsonData.id="+jsonData.id);
				layui.use(['layer', 'form', 'element','table','laydate'], function(){});
			} else {
					alert(jsonData.resultMessage);
				}
			});
	}else{
		$("#theActionTxt").text("添加系统角色");

	}
}
	
/**
 * 打开页面时，加载所有菜单及功能到设置权限面板
 */
fetchAllSystemMenuAndFunction();
function fetchAllSystemMenuAndFunction(){
	AjaxPostFn( 'system/menuControl/listAllMenuFunction.do', "{}", function(jsonData) {
		if(jsonData.resultCode=="200"){
			var data = jsonData.list;
			
			$("#leftMenuTree").empty();
			$.each(jsonData.list,function(indexRoot,oneRootMenu){
				var oneMenuStr='<div class="souquan_index">';				
				oneMenuStr+='<p menu-id="'+oneRootMenu.id+'">';
				oneMenuStr+='<input onclick="return doThisCheckBoxCanBeChange('+indexRoot+',0,0,this)" menu-id="'+oneRootMenu.id+'" menu-index='+indexRoot+' type="checkbox" class="checkbox_left checkbox">';
				oneMenuStr+='<i class="layui-icon">&#xe7a0;</i>';
				oneMenuStr+=oneRootMenu.name;
				oneMenuStr+='</p>';
				oneMenuStr+='<ul>';
				$.each(oneRootMenu.subMenuList,function(indexSub,oneSubMenu){
					oneMenuStr+='<li onclick="showMenuFunctions(\''+oneSubMenu.id+'\')">';
					oneMenuStr+='<input onclick="return doThisCheckBoxCanBeChange('+indexRoot+','+indexSub+',0,this)" parent-id="'+oneRootMenu.id+'" menu-id="'+oneSubMenu.id+'"  menu-sub-index='+indexRoot+''+indexSub+' type="checkbox" class="checkbox_left checkbox">';
					oneMenuStr+='<i class="layui-icon">&#xe7a0;</i>';
					oneMenuStr+='<span menu-id="'+oneSubMenu.id+'" onclick="showMenuFunctions(\''+oneSubMenu.id+'\');">'+oneSubMenu.name+'</span>';
					oneMenuStr+='</li>';
					
					var oneMenuFunStr='<ul style="display:none;" menu-id="'+oneSubMenu.id+'">';
					$.each(oneSubMenu.functionList,function(indexFun,oneFun){
						oneMenuFunStr+='<li>';
						oneMenuFunStr+='<input onclick="return doThisCheckBoxCanBeChange('+indexRoot+','+indexSub+','+indexFun+',this)" parent-id="'+oneRootMenu.id+'" menu-id="'+oneSubMenu.id+'" func-id="'+oneFun.id+'" func-index='+indexRoot+''+indexSub+''+indexFun+' type="checkbox" class="checkbox_left checkbox">';
						oneMenuFunStr+=oneFun.name;
						oneMenuFunStr+='</li>';
					});
					oneMenuFunStr+='</ul>';
					$("#rightUpFunction").append(oneMenuFunStr);

				});
				oneMenuStr+='</ul>';
				oneMenuStr+='</div>';
				$("#leftMenuTree").append(oneMenuStr);
			});
		}
	});	
}

function disRedFont(){
	$('#leftMenuTree').on("click","li",function(){
	var menuList = $("#leftMenuTree li");
		menuList.removeClass("redFont");
		$(this).addClass("redFont");
	});
}


function showSou(theObj){
	curRoleName = $(theObj).attr("rolename");
	curRoleId = $(theObj).attr("roleid");
	$("#theRoleName").text(curRoleName);
	$("#curRoleId").val(curRoleId);
	$("#rightUpFunction ul:eq(0)").show();//右边边默认显示第一个功能块
	$("#leftMenuTree input:checkbox[menu-index='0']").prop("checked",true);//默认第一个菜单选中
	$("#leftMenuTree input:checkbox[menu-sub-index='00']").prop("checked",true);//默认第一个子菜单选中
	$("#rightUpFunction input:checkbox[func-index='000']").prop("checked",true);//默认选中第一个功能
	
	AjaxPostFn( '/system/roleMenuControl/listConsoleRoleMenu.do', '{"roleId":"'+curRoleId+'","pageSize":1000}', function(jsonData) {
		if(jsonData.resultCode=="200"){
			console.log("menuList:"+jsonData.list);
			$.each(jsonData.list,function(index,oneData){
				//console.log(oneData.menuId);
				$("#leftMenuTree input:checkbox[menu-id='"+oneData.menuId+"']").prop("checked",true);
			});
		}
	});

//	AjaxPostFn( '/system/roleFunctionControl/listConsoleRoleFunction.do', '{"roleId":'+curRoleId+',"pageSize":1000}', function(jsonData) {
//		if(jsonData.resultCode=="200"){
//			console.log("functionList:"+jsonData.list);
//			$.each(jsonData.list,function(index,oneData){
//				//console.log(oneData.functionId);
//				$("#rightUpFunction input:checkbox[func-id='"+oneData.functionId+"']").prop("checked",true);
//			});
//		}
//		//判断是否全选左边功能框
//		checkNeedAllBoxBeChecked();		
//	});
	

	//显示搜索框
	souquan.style.display = "block";
}

/**
 * 如果为第一个选择框，点击无效
 */
function doThisCheckBoxCanBeChange(rootIndex,subIndex,funIndex,obj){
	//console.log(rootIndex+","+subIndex+","+funIndex);
	if(rootIndex==0&&subIndex==0&&funIndex==0){
		return false;
	}else{
		var parentId=$(obj).attr("parent-id")||-1;
		var functionId=$(obj).attr("func-id")||-1;
		if(parentId<0){//选择不是第一个的根目录
			if($(obj).is(":checked")==true){
				$("#leftMenuTree input:checkbox[parent-id='"+$(obj).attr("menu-id")+"']").prop("checked",true);
				$("#rightUpFunction input:checkbox[parent-id='"+$(obj).attr("menu-id")+"']").prop("checked",true);
				$("#theCheckAll").prop("checked",true);
			}else{
				$("#leftMenuTree input:checkbox[parent-id='"+$(obj).attr("menu-id")+"']").prop("checked",false);
				$("#rightUpFunction input:checkbox[parent-id='"+$(obj).attr("menu-id")+"']").prop("checked",false);
				$("#theCheckAll").prop("checked",false);
			}			
		}else if(functionId<0){//选择子路径,则所有的功能菜单都选中
			var selectedSubLength=$("#leftMenuTree input:checkbox[parent-id='"+$(obj).attr("parent-id")+"']:checked").length;
			if(selectedSubLength>0){
				$("#leftMenuTree input:checkbox[menu-id='"+$(obj).attr("parent-id")+"']").prop("checked",true);
			}else{
				$("#leftMenuTree input:checkbox[menu-id='"+$(obj).attr("parent-id")+"']").prop("checked",false);
			}
			//等显示后再切换选中
			setTimeout(function(){
				checkCurrentAllFunction(obj);
				//判断是否全选左边功能框
				checkNeedAllBoxBeChecked();
			},5);
		}else if(functionId>=0){//功能选中
			var menuId=$(obj).attr("menu-id");
			var selectedFuncLength=$("#rightUpFunction input:checkbox[menu-id='"+menuId+"']:checked").length;
			var allFuncLength=$("#rightUpFunction input:checkbox[menu-id='"+menuId+"']").length;
			if(selectedFuncLength>0){
				$("#leftMenuTree input:checkbox[menu-id='"+menuId+"']").prop("checked",true);
				if(allFuncLength==selectedFuncLength){
					$("#theCheckAll").prop("checked",true);
				}
			}else{
				$("#leftMenuTree input:checkbox[menu-id='"+menuId+"']").prop("checked",false);
				$("#theCheckAll").prop("checked",false);
			}
		}
		return true;
	}
}

/**
 * 功能全选按钮点击选中全部
 */
function checkCurrentAllFunction(obj){
	//console.log($(obj).is(":checked")+"  "+$("#rightUpFunction input:checkbox:visible").length);
	if($(obj).is(":checked")==true){
		$("#rightUpFunction ul input:checkbox:visible").prop("checked",true);
	}else{
		$("#rightUpFunction ul input:checkbox:visible").prop("checked",false);
		$("#rightUpFunction input:checkbox[func-index='000']").prop("checked",true);//默认第一个菜单
	}
}
/**
 * 判断单个功能是否已全部选中，全部选中就把全选按钮选中
 */
function checkNeedAllBoxBeChecked(){
	var theSelectedFuncLength=$("#rightUpFunction ul input:checkbox:visible:checked").length||0;
	//console.log("theSelectedFuncLength="+theSelectedFuncLength);
	if(theSelectedFuncLength==0){
		$("#theCheckAll").prop("checked",false);
	}else{
		var theMenuId=$("#rightUpFunction ul input:checkbox:visible:checked :first").attr("menu-id");
		var theShowLength=$("#rightUpFunction ul input:checkbox:visible:checked").length;
		if(theShowLength==theSelectedFuncLength){
			$("#theCheckAll").prop("checked",true);
		}
		//console.log("theShowLength="+theShowLength);
		//console.log("theMenuId="+theMenuId);
	}
}

function showMenuFunctions(menuId){
	$("#rightUpFunction ul[menu-id='"+menuId+"']").show();//等于menuid的显示
	$("#rightUpFunction ul[menu-id!='"+menuId+"']").hide();//不等于就不显示
	checkNeedAllBoxBeChecked();
}
/**
 * 保存角色与权限
 */
function saveRoleMenuAndFunction(){
	//console.log($("#leftMenuTree input:checkbox:checked").length);
	var curRoleId=$("#curRoleId").val();
	var selectedMenuJson=new Array();
	$.each($("#leftMenuTree input:checkbox:checked"),function(index,oneBox){
		selectedMenuJson.push({"roleId":curRoleId,"menuId":$(oneBox).attr("menu-id")});
	});
	//console.log(selectedMenuJson);
	var selectedFunctionJson=new Array();
	$.each($("#leftMenuTree input:checkbox:checked"),function(index,oneBox){
		selectedFunctionJson.push({"roleId":curRoleId});
	});
	
	//console.log(selectedFunctionJson);
	
	AjaxPostFn( '/system/roleMenuControl/saveConsoleRoleMenuBatch.do',JSON.stringify(selectedMenuJson), function(menuResult) {
		if(menuResult.resultCode=="200"){
			if(menuResult.resultCode=="200"){
					layer.open({
						  title: '保存成功'
						  ,content: '保存成功'
					});
					closeSou();
			}else{
					layer.open({
						  title: '保存失败'
						  ,content: funcResult.resultMessage
					});						
			}
			
			
			AjaxPostFn( '/system/roleFunctionControl/saveConsoleRoleFunctionBatch.do',JSON.stringify(selectedFunctionJson), function(funcResult) {
				if(funcResult.resultCode=="200"){
					layer.open({
						  title: '保存成功'
						  ,content: '保存成功'
					});
					closeSou();
				}else{
					layer.open({
						  title: '保存失败'
						  ,content: funcResult.resultMessage
					});						
				}
			})			
		}else{
			layer.open({
				  title: '保存失败'
				  ,content: menuResult.resultMessage
			});			
		}
	})
}
//
function closeSou(){
	$(".souquan input:checkbox").prop("checked",false);
	$("#rightUpFunction ul").hide();
    souquan.style.display = 'none';
}


	var roleSubit = document.getElementById('roleSubit');
	var authorization = document.getElementById('authorization');
	var souquan = document.getElementsByClassName('souquan')[0];
	var souquan_left = document.getElementsByClassName('souquan_left')[0];
	var souquan_rightul = document.getElementsByClassName('souquan_rightul')[0];
	var rolename = document.getElementsByClassName('rolename')[0];
	var curActivedMenuList = [];
	var curActivedSubMenuList = [];
	var storage_leftMenu = [];
	var storage_rightMenu = [];
	var curRoleId = "";
	
	//修改联调
	function resave_role(){
		var resave = document.getElementsByClassName('resave')[0];
		var repair = document.getElementsByClassName('repair')[0];
		var roleid = getEvent().srcElement.getAttribute("roleid");
		var role_name = repair.getElementsByClassName('role_name')[0];
		var role_description = repair.getElementsByClassName('role_description')[0];
		var repairRoleSubit = document.getElementById('repairRoleSubit');
		
		AjaxPostFn( '/system/roleControl/getConsoleRole.do', '{"id":roleid}', function(jsonData) {
			role_name.value = jsonData.name;
			role_description.value = jsonData.description;
		})
		resave.style.display = 'block';
		repairRoleSubit.onclick = function(){
			role_name = repair.getElementsByClassName('role_name')[0].value;
			role_description = repair.getElementsByClassName('role_description')[0].value;
			AjaxPostFn( '/system/roleControl/saveConsoleRole.do', '{"id":'+roleid+',"name":'+role_name+',"description":'+role_description+'}', 
			function(jsonData) {
				
			})
		}
		
	}
	
	
	var getEvent = function(){
	    return window.event || arguments.callee.caller.arguments[0];
	}




	/*删除*/
	function delete_role() {
		
		parentId = getEvent().srcElement.getAttribute('parentId');
		var popup = '<div class="layui-row">'+
                    '<div class="layui-col-md12 layui-hint">'+
                    	'<p>您真的确定要删除角色吗？</p>'+
                    	'<p>可能会造成对应的用户缺少权限\n\n请确认！</p>'+
                    '</div>'+
                    '<div class="layui-col-md12 layui-hint-btn">'+
                        '<button type="button" class="layui-btn confirm" id="confirmBtn">确认</button>'+
                        '<button type="button" class="layui-btn cancel" id="cancelBtn">取消</button>'+
                    '</div>'+
                '</div>';
		var hint = layer.open({
			type: 1,
			area: ['360px','180px'],
			title: "提示信息", 
			resize: false,
			content : popup,
			success: function(layero, index){
			},
			cancel: function(index, layero){ 
			}    
		});
	
		// 关闭弹出层
		$("#cancelBtn").click(function(){
			layer.close(hint); 
		})
	
		//  确认删除
		$("#confirmBtn").click(function(){
			AjaxPostFn( '/system/roleControl/deleteConsoleRole.do', '{"id":parentId}', function(jsonData){
			    if(jsonData.resultCode==200){
			        // console.log(jsonData)
			        layer.close(hint); 
			        doSearch();
			        layer.msg('删除成功');
			    }else{
			    	layer.msg(jsonData.resultMessage);
			        // alert("您已经久未操作,请重新登录!",gotoLogin());
			    }
			});
		})
		
	}



function showdiv() {            
     document.getElementById("bg").style.display = "block";
     document.getElementById("show").style.display = "block";
}
function hidediv() {
    document.getElementById("bg").style.display = 'none';
    document.getElementById("show").style.display = 'none';
    document.getElementsByClassName('resave')[0].style.display = 'none';
    souquan.style.display = 'none';
}
/**
 * 时间戳转换具体时间
 * @param {Object} now
 */
function formatDate(now) { 
	var nowDate = new Date(now);
	var year=nowDate.getFullYear(); 
	var month=nowDate.getMonth()+1; 
	var odate=nowDate.getDate(); 
	var hour=nowDate.getHours(); 
	var minute=nowDate.getMinutes(); 
	return year+"-"+month+"-"+odate+" "+hour+":"+minute; 
} 

</script>

	</body>

</html>